package com.care.patient.server.controller;

import com.care.common.core.domain.Result;
import com.care.common.core.result.PageResult;
import com.care.doctor.remote.DepartmentRemoteService;
import com.care.doctor.remote.LabelRemoteService;
import com.care.wardmate.common.domain.Article;
import com.care.wardmate.common.domain.Review;
import com.care.wardmate.common.request.ArticleRequest;
import com.care.wardmate.remote.ArticleRemoteService;
import com.care.wardmate.remote.ReviewRemoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/medic")
public class MedicController {
    @Autowired
    private ArticleRemoteService articleRemoteService;
    @Autowired
    private LabelRemoteService labelRemoteService;
    @Autowired
    private DepartmentRemoteService departmentRemoteService;
    @Autowired
    private ReviewRemoteService reviewRemoteService;

    @PostMapping("/selectArticle")
    public Result<PageResult<Article>> selectArticle(@RequestBody ArticleRequest articleRequest) {
        labelRemoteService.findByLabelId(articleRequest.getLabelId());
        return articleRemoteService.selectArticle(articleRequest);
    }

    @GetMapping("/label/listAll")
    public Result listAll() {
        return labelRemoteService.listAll();
    }

    @GetMapping("/department/selectAll")
    public Result selectAll(){
        return departmentRemoteService.listAll();
    }

    @GetMapping("selectReviewById/{articleId}")
    public Result<List<Review>> selectReviewById(@PathVariable Integer articleId){
        return reviewRemoteService.selectReviewById(articleId);
    }

    @GetMapping("/selectArticleById/{articleId}")
    public Result<Article> selectArticleById(@PathVariable Integer articleId){
        return articleRemoteService.selectArticleById(articleId);
    }
}
